<html>
<head><meta charset="utf-8"><title>Forward-progress guarantee · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html">Forward-progress guarantee</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172440445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172440445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172440445">(Aug 04 2019 at 08:26)</a>:</h4>
<p>It looks like I misunderstood the direction in which forward-progress guarantees in LLVM are headed. Apparently the current stance is that forward-progress is required and llvm.sideeffect is the final solution to this issue, not just a temporary workaround.</p>



<a name="172441784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172441784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172441784">(Aug 04 2019 at 09:13)</a>:</h4>
<p>Wow :(</p>



<a name="172441789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172441789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172441789">(Aug 04 2019 at 09:13)</a>:</h4>
<p>do they plan to fix clang? (currently LLVM, to my knowledge, violates the C standard by requiring forward progress even for loops where the conditional is a constant)</p>



<a name="172450968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172450968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172450968">(Aug 04 2019 at 14:07)</a>:</h4>
<p>Any context? I did not get any pings on relevant bugs.</p>



<a name="172451132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172451132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172451132">(Aug 04 2019 at 14:12)</a>:</h4>
<p>Direct context is <a href="https://reviews.llvm.org/D59978" target="_blank" title="https://reviews.llvm.org/D59978">https://reviews.llvm.org/D59978</a>, though more relevant is <a href="http://lists.llvm.org/pipermail/llvm-dev/2015-July/088095.html" target="_blank" title="http://lists.llvm.org/pipermail/llvm-dev/2015-July/088095.html">http://lists.llvm.org/pipermail/llvm-dev/2015-July/088095.html</a>.</p>



<a name="172461474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461474">(Aug 04 2019 at 19:47)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> seems worth asking how they plan to implement the "unless loop conditional is a constant" part of the C spec. Also I dont think C makes a forward progress assumption for recursive functions; the quoted part of the standard is specifically about loops.</p>



<a name="172461525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461525">(Aug 04 2019 at 19:49)</a>:</h4>
<p>or maybe I can read what they say in there as them saying that stack overflow is UB, which would be... really, really bad news for guard pages as they become useless. well not practically useless but from a principled perspective.</p>



<a name="172461686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461686">(Aug 04 2019 at 19:54)</a>:</h4>
<p>I've opened <a href="https://reviews.llvm.org/D65718" target="_blank" title="https://reviews.llvm.org/D65718">https://reviews.llvm.org/D65718</a> to document this ... but based on the initial comments maybe the comments on that thread do not actually represent the current consensus.</p>



<a name="172461693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461693">(Aug 04 2019 at 19:54)</a>:</h4>
<p>Someone recently started a thread on llvm-dev to clarify stack overflow behavior, no responses yet though.</p>



<a name="172461706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461706">(Aug 04 2019 at 19:55)</a>:</h4>
<p>Tangentially related, I've been baited into finally implementing the -Z flag I proposed here <a href="https://github.com/rust-lang/rust/issues/28728#issuecomment-426247247" target="_blank" title="https://github.com/rust-lang/rust/issues/28728#issuecomment-426247247">https://github.com/rust-lang/rust/issues/28728#issuecomment-426247247</a> to see how bad the impact really is</p>



<a name="172461750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461750">(Aug 04 2019 at 19:56)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> thanks for pointing us to the llvm-dev thread(s), I hope to chime in there as well (after catching up)</p>



<a name="172461816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461816">(Aug 04 2019 at 19:58)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> Did you see <a href="https://github.com/rust-lang/rust/pull/59546" target="_blank" title="https://github.com/rust-lang/rust/pull/59546">https://github.com/rust-lang/rust/pull/59546</a>?</p>



<a name="172461823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461823">(Aug 04 2019 at 19:59)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> do you know if there is any basis in C for removing infinite recursion with no side-effects?</p>



<a name="172461825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461825">(Aug 04 2019 at 19:59)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span>  Oh dear. I did not.</p>



<a name="172461834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461834">(Aug 04 2019 at 19:59)</a>:</h4>
<p>That has some indication about just how bad it is. Though I think that it's somewhat overly pessimistic, because it places sideeffect intrinsics on every call instead of on every function entry.</p>



<a name="172461896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461896">(Aug 04 2019 at 20:01)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> is "current" discussion happening on the list or that review you linked? What would likely be the better place to respond?</p>



<a name="172461899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461899">(Aug 04 2019 at 20:01)</a>:</h4>
<p>(asking because I am not very familiar with the ways of LLVM. still takes me several minutes, once I wrote a patch, to submit it for review there. I had no idea that non-PR-based workflows are <em>so bad</em> until I was subject to this one. I mean I worked on KDE which also used/uses a reviewboard, but there at least I could just <code>git push</code> "into the reviewboard", so things were much easier. manually picking reviewers as a dont-know-anything new contributor still sucked though.)</p>



<a name="172461958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172461958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172461958">(Aug 04 2019 at 20:03)</a>:</h4>
<blockquote>
<p>That has some indication about just how bad it is. Though I think that it's somewhat overly pessimistic, because it places sideeffect intrinsics on every call instead of on every function entry.</p>
</blockquote>
<p>I only see perf results, which measure compile time as much as optimization impact. It seems nobody has provided lolbench results (or other measurements) so far. Is that correct?</p>



<a name="172462005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462005">(Aug 04 2019 at 20:04)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> For stack overflows I'd respond to <a href="http://lists.llvm.org/pipermail/llvm-dev/2019-August/134317.html" target="_blank" title="http://lists.llvm.org/pipermail/llvm-dev/2019-August/134317.html">http://lists.llvm.org/pipermail/llvm-dev/2019-August/134317.html</a>. For forward-progress in general probably best on <a href="https://reviews.llvm.org/D65718" target="_blank" title="https://reviews.llvm.org/D65718">https://reviews.llvm.org/D65718</a>, I don't think there has been a recent mailing list discussion on this.</p>



<a name="172462014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462014">(Aug 04 2019 at 20:05)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> thanks</p>



<a name="172462070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462070">(Aug 04 2019 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> Yeah, those are only compile time results (though check build regressions should be pure run-time regressions). Compile-time is a big concern as well though, because llvm.sideeffect really blows up the IR without some kind of coalescing.</p>



<a name="172462140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462140">(Aug 04 2019 at 20:09)</a>:</h4>
<p>Sure, the compile time regression sucks, but it's much less important than missed optimizations IMO (and apparently also in the eyes of the compiler team)</p>



<a name="172462289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462289">(Aug 04 2019 at 20:13)</a>:</h4>
<p>I think for that PR we ideally want to do codegen analysis pass (we have some for e.g. SSA-ization of our MIR values. something similar to that)</p>



<a name="172462293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462293">(Aug 04 2019 at 20:13)</a>:</h4>
<p>and then just stick a <code>sideeffect</code> in the entry point of that function which should not be optimised out.</p>



<a name="172462342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462342">(Aug 04 2019 at 20:14)</a>:</h4>
<p>at least currently LLVM is not smart enough to remove the loops themselves, rather it is only removing calls to functions that contain such infinite loops.</p>



<a name="172462358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462358">(Aug 04 2019 at 20:15)</a>:</h4>
<p>but for perf evaluation I think whatever approach works.</p>



<a name="172462365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462365">(Aug 04 2019 at 20:15)</a>:</h4>
<p>What sort of analysis are you thinking of? Finding loops?</p>



<a name="172462424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462424">(Aug 04 2019 at 20:17)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> It's not so much that LLVM isn't smart enough, but that it currently has explicit checks to not remove potentially infinite loops.</p>



<a name="172462475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462475">(Aug 04 2019 at 20:18)</a>:</h4>
<blockquote>
<p>What sort of analysis are you thinking of? Finding loops?</p>
</blockquote>
<p>Analysis which figures out whether we need to smack a <code>sideeffect</code> into the function. It can be as simple as "if there is a loop" or as complicated "this particular pattern makes semantics currently not match".</p>



<a name="172462482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462482">(Aug 04 2019 at 20:18)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> It's not so much that LLVM isn't smart enough, but that it currently has explicit checks to not remove potentially infinite loops.</p>
</blockquote>
<p>Okay, "smart enough to not remove".</p>



<a name="172462496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462496">(Aug 04 2019 at 20:19)</a>:</h4>
<p>Because of recursion, "there's a loop" is not enough.</p>



<a name="172462550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462550">(Aug 04 2019 at 20:20)</a>:</h4>
<p>lol... searching for "C is stack overflow undefined behavior" is not as helpful as one might think because a certain site decided to pick a particular name...</p>



<a name="172462553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462553">(Aug 04 2019 at 20:21)</a>:</h4>
<p>Stack overflow is a buffer overrun, so they are equivalent.</p>



<a name="172462562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462562">(Aug 04 2019 at 20:21)</a>:</h4>
<p>I dont think the C standard specifies the stack as a buffer</p>



<a name="172462566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462566">(Aug 04 2019 at 20:21)</a>:</h4>
<p>C standard will not specify anything much about stack at all, because that’s a concern for an ABI document.</p>



<a name="172462610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462610">(Aug 04 2019 at 20:22)</a>:</h4>
<p>At least that’s my intuition, I haven’t C standard in my head.</p>



<a name="172462612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462612">(Aug 04 2019 at 20:22)</a>:</h4>
<p>I hope nobody does, they could go right to the asylum...</p>



<a name="172462613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462613">(Aug 04 2019 at 20:22)</a>:</h4>
<p>but I do know that ABI documents usually take the responsibility of specifying stack.</p>



<a name="172462618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462618">(Aug 04 2019 at 20:22)</a>:</h4>
<p>the other tricky bit is that the compiler is certainly allowed to turn stack overflows into working code, e.g. by removing unused local variables</p>



<a name="172462619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462619">(Aug 04 2019 at 20:23)</a>:</h4>
<p>ABI documents aren't (shouldn't) be in the business of settling whether something is UB or not, though</p>



<a name="172462624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462624">(Aug 04 2019 at 20:23)</a>:</h4>
<p>that could be specified very precisely by saying "on the Abstract Machine, any time a function is called, execution <em>might</em> halt due a stack overflow"</p>



<a name="172462628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462628">(Aug 04 2019 at 20:23)</a>:</h4>
<p>but of course such precision is not achieved by the C spec</p>



<a name="172462670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462670">(Aug 04 2019 at 20:24)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> ABI document does not set what UB is or isn’t, but it does (and should) specify what stack is.</p>



<a name="172462672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462672">(Aug 04 2019 at 20:24)</a>:</h4>
<p>Which usually is a buffer that "grows downwards".</p>



<a name="172462689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462689">(Aug 04 2019 at 20:24)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> but in no way does that make it a buffer in any C sense</p>



<a name="172462697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462697">(Aug 04 2019 at 20:25)</a>:</h4>
<p>/me shrugs</p>



<a name="172462699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462699">(Aug 04 2019 at 20:25)</a>:</h4>
<p>like, ABIs also define frame pointers and return pointers and stuff</p>



<a name="172462701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462701">(Aug 04 2019 at 20:25)</a>:</h4>
<p>and still it is UB to observe those from C</p>



<a name="172462746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462746">(Aug 04 2019 at 20:26)</a>:</h4>
<p>ABIs are basically mostly hardware-level documents. they don't really say anything about what the C Abstract Machine does, AFAIK.</p>



<a name="172462747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462747">(Aug 04 2019 at 20:26)</a>:</h4>
<p>some aspects of ABI feed back, such as sizes of types</p>



<a name="172462753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462753">(Aug 04 2019 at 20:26)</a>:</h4>
<p>but those are explicitly accounted for in a precise Abstract Machine spec: "each type has an implementation-defined size, ..."</p>



<a name="172462818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462818">(Aug 04 2019 at 20:29)</a>:</h4>
<p>I guess there is one example (SPARC) where stack is not a buffer at all.</p>



<a name="172462865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Forward-progress%20guarantee/near/172462865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Forward-progress.20guarantee.html#172462865">(Aug 04 2019 at 20:30)</a>:</h4>
<p>(well, it is in a sense that it is still a few pages of memory), but the actual hardware requires it to be used in a very specific manner which disallows to treat it that way</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>